package com.yuneec.droneservice.command;

import com.yuneec.droneservice.model.StatusInfo;
import com.yuneec.droneservice.request.IResponse;

/**
 * Created by gjw on 2017/3/27.
 */

public class GetStatus extends BaseCommand {
    public GetStatus() {
        super(MAV_RC_COMMAND.MAV_RC_CMD_GET_STATE);
    }

    @Override
    public IResponse<StatusInfo> toResponse(byte[] data, int off, int len) {
        int code = data[off + 1] & 0xff;
        IResponse<StatusInfo> response = new IResponse(ids(), code);
        if (code == MAV_RC_ERROR_CODE.MAV_RC_ERR_SUCCESS) {
            StatusInfo statusInfo = new StatusInfo();
            statusInfo.setUpgradeState(data[off + 2]);
            response.setParam(statusInfo);
        }
        return response;
    }

}
